<?php
namespace app\daifast\controller;
use \think\Db;
use think\Session;


class Message extends \think\Controller
{ 
    
    
    
    /**
     * 留言列表
     */
    public function index(){
         
        
        $names = addslashes(input('names'));
        $status = intval(input('status'));
        $type = intval(input('type'));
        //查询条件
        $where = " 1=1 ";
        $names and $where .=" and names = '".$names."'"; 
        $status and $where .=" and status = ".$status;
        $type and $where .=" and type = ".$type;
        
        $pageQueryArr =["query"=>["names"=>$names,'status'=>$status,'type'=>$type]];
        $data = Db('baode_message')->where($where)->order("status desc,id desc")->paginate(10,$pageQueryArr); 
        $listArr = $data->items();
        $pages = $data->render(); 
        
        return $this->allFetch(get_defined_vars());
    }
     
    /**
     * 改变留言状态值
     */
    public function reset(){
        $id = input('id');
        
        Db('baode_message')->where(['id'=>intval($id)])->update(['status'=>'1']);
        
        $this->showMsg('操作成功', url('Message/index'));
        
        
    }
}
